package com.example.djetpack

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import com.example.djetpack.lifecycle.LifecycleActivity
import com.example.djetpack.livedata.HiEventBus
import com.example.djetpack.livedata.HiEventBusActivity
import com.example.djetpack.livedata.LiveDataHandler

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }

    fun lifecycle(view: View) {
        startActivity(Intent(this@MainActivity, LifecycleActivity::class.java))
    }

    fun postHiEvent(view: View) {
        HiEventBus.with<String>("Message").postValue("hello my HiEvent")
        startActivity(Intent(this@MainActivity, HiEventBusActivity::class.java))
    }

    fun postLiveData(view: View) {
        LiveDataHandler.liveData.postValue("Hi I am LiveData sticky消息")
        startActivity(Intent(this@MainActivity, HiEventBusActivity::class.java))
    }
}